<?php
require_once 'modules/list/models/List.php';
require_once  'modules/mail/models/Mail.php';
require_once  'modules/user/models/User.php';
require_once 'Zend/Validate/EmailAddress.php';
require_once 'modules/content/models/Content.php';
require_once 'modules/content/models/ContentCategory.php';
class right_menuSticker extends Nine_Sticker
{
	public function run()
	{
		
	 	$data = Nine_Controller_Front::getInstance()->getRequest()->getParam('data', false);
	    $errors = array();
	    $condition = array();
			    
		
		$objContent = new Models_Content();
		$objContentCategory = new Models_ContentCategory();
		 $gidService = 3;		
		$allService = $objContent->getAllEnabledContentByCategory($gidService,array('content_id DESC'));
		$i = 0;
		$service = array();
		
		foreach ($allService as &$item) {
			if(2!=$i){
				$item['main_title'] = $item['title'] ;
				$item['title'] = Nine_Function::subStringAtBlank(trim(strip_tags($item['title'])),30);
        	$item['intro_text'] = Nine_Function::subStringAtBlank(trim(strip_tags($item['intro_text'])), 85);        	
        	$item['url'] = Nine_Route::_("content/index/detail/id/{$item['content_gid']}");
        	$tmp = explode('||', $item['images']);
//			$content['main_image'] = Nine_Function::getThumbImage(@$tmp[0], 244, 191);
			$item['main_image']= Nine_Function::getThumbImage(@$tmp[0], 72, 46,null,true);
				$service[] = $item;
				$i++;
			}
			else{
				break;
			}
		}
		unset($item);
		$gidNews = 5;
		$allNews = $objContent->getAllEnabledContentByCategory($gidNews,array('content_id DESC'));
		$j = 0;
		$news = array();
		foreach ($allNews as &$item) {
			if(2!=$j){
				$item['main_title'] = $item['title'];
				$item['title'] = Nine_Function::subStringAtBlank(trim(strip_tags($item['title'])),30);
        	$item['intro_text'] = Nine_Function::subStringAtBlank(trim(strip_tags($item['intro_text'])), 85);        	
        	$item['url'] = Nine_Route::_("content/index/detail/id/{$item['content_gid']}");
        	$tmp = explode('||', $item['images']);
//			$content['main_image'] = Nine_Function::getThumbImage(@$tmp[0], 244, 191);
			$item['main_image']= Nine_Function::getThumbImage(@$tmp[0], 72, 46,null,true);
			$j++;
				$news[] = $item;
			}
			else{
				break;
			}
		}
		
	
		
		
		
		$objList = new Models_List();
        $list = $objList->getAllLists();
        
		$yahoo = array();
		$skype = array();
		$phone = array();
		$mail = array();
		foreach ($list as $item) {
			if(1==$item['parent_id']){
				$yahooId = $item['custom_value'];
				$ch = curl_init("http://opi.yahoo.com/online?u=".$yahooId."&m=t");
				curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
				$status = curl_exec($ch);
				curl_close($ch);
				$pos = strpos($status, "NOT");
				  if($pos !== false || (null == $item['custom_value'])){
				  	$item['status'] = 0 ;
				  }
				  else{
				  	$item['status'] = 1 ;
				  }
		      
				$yahoo []= $item;
			}
			elseif(2 == $item['parent_id']){
				$skype [] = $item;
			}
			elseif (3 == $item['parent_id']){
				$phone [] = $item;
			}
			elseif(4 == $item['parent_id']) {
				$mail[] = $item;
			}
		}
		
		
		
		
		
		$this->view->news =  $news;
		$this->view->service = $service;
		$this->view->yahoo = $yahoo;
		$this->view->skype = $skype;
		$this->view->phone = $phone;
		$this->view->mail = $mail;
		
		
	
	
		
		 
		
		
	}
}